import time
from selenium.webdriver.common.by import By
from Base.Base import Base


class Page(Base):
    # 点击月考
    click_yuekao_loc = (By.XPATH, '/html/body/div[1]/div/section/aside/ul/li[1]/div/i[2]/svg')

    def click_yuekao(self):
        self.click(self.click_yuekao_loc)

    # 点击用户注册
    click_register_loc = (By.XPATH, '/html/body/div[1]/div/section/aside/ul/li/ul/li[7]')
    def click_register(self):
        self.click(self.click_register_loc)

    # 输入用户名
    send_name_loc = (By.XPATH, '/html/body/div[1]/div/section/section/main/div/div[2]/div[1]/div/input')
    def send_name(self):
        self.send_keys(self.send_name_loc, 'wmm7')

    # 输入密码
    send_password_loc = (By.XPATH, '/html/body/div[1]/div/section/section/main/div/div[2]/div[2]/div/input')
    def send_password(self):
        self.send_keys(self.send_password_loc, '123456Aa')

    # 点击立即注册按钮
    click_register_button_loc = (By.XPATH, '/html/body/div[1]/div/section/section/main/div/div[2]/button')
    def click_register_button(self):
        self.click(self.click_register_button_loc)

    # 业务逻辑
    def Item_user_register(self):
        self.open_url('http://localhost:8081/')
        self.click_yuekao()
        self.click_register()
        # time.sleep(2)
        self.send_name()
        self.send_password()
        self.click_register_button()

